package com.hbjycl.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.hbjycl.dao.RoleDao;
import com.hbjycl.entity.Admin;
import com.hbjycl.entity.Role;

@Repository
@Transactional
public class RoleDaoImpl extends BaseDaoImpl<Role, String> implements RoleDao
{
    
    @Override
    public Role getByName(String name)
    {
        String hql = "from Role role where role.name=?";
        return (Role) getSession().createQuery(hql).setParameter(0, name).uniqueResult();
    }
   
    
    @Override
    public Role getByValue(String value)
    {
        String hql = "from Role role where role.value=?";
        return (Role) getSession().createQuery(hql).setParameter(0, value).uniqueResult();
    }
    
    @Override
    public List<Admin> getAdminList(String roleId)
    {
        String hql = "select adminSet from Role role where role.id=?";
        return (List<Admin>) getSession().createQuery(hql).setParameter(0, roleId).list();
    }
    
}
